package com.wenyang.service.impl;

import com.wenyang.dao.RouteImgDao;
import com.wenyang.entity.TabRouteImg;
import com.wenyang.service.RouteImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class RouteImgServiceImpl implements RouteImgService {

    @Autowired
    private RouteImgDao routeImgDao;

    @Override
    public List<TabRouteImg> findAllRouteImg() {
        return routeImgDao.findAllRouteImg();
    }

    @Override
    public List<TabRouteImg> findRouteImgById(int rid) {
        String url = "https://20240416-wenyangfile.oss-cn-beijing.aliyuncs.com/";
        List<TabRouteImg> tabRouteImgs = new ArrayList<>();
        List<TabRouteImg> routeImgById = routeImgDao.findRouteImgById(rid);
        for (TabRouteImg tabRouteImg : routeImgById) {
            tabRouteImg.setTitleImg(url+tabRouteImg.getTitleImg());
            tabRouteImg.setBigPic(url+tabRouteImg.getBigPic());
            tabRouteImg.setSmallPic(url+tabRouteImg.getSmallPic());
            tabRouteImgs.add(tabRouteImg);
        }
        return tabRouteImgs;
    }
}
